/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package unidad_3;

import java.awt.*;
import java.awt.event.*;
/**
 *
 * @author jcverdia
 */
public class Textos {
     private static class Ventana {

        public Ventana() {
            Frame f=new Frame();

           //-----------------------
            MenuBar menub=new MenuBar();
            final Menu m=new Menu(" Archivo");
            m.add("Nuevo");
            m.add("Salir");
            menub.add(m);
            f.setMenuBar(menub);


         //-----------------------


        f.setLayout(new GridLayout(3,1));

        Panel p1=new Panel();
        p1.setLayout(new GridLayout(1,1));
        p1.setBackground(Color.yellow);

        Panel p2=new Panel();
        p2.setBackground(Color.BLUE);


        Panel p3=new Panel();
        p3.setBackground(Color.yellow);


        Panel p3A=new Panel();
        p3A.setLayout(new GridLayout(1,2));
        p3.add(p3A);

        final TextArea At=new TextArea();
        final Button b=new Button("Agregar");
        final TextField fie=new TextField();
        fie.setSize(300, 300);

        p2.add(At);
        p3A.add(fie);



        p3A.add(b);


        f.add(p1);
        f.add(p2);
        f.add(p3);

        b.addMouseListener(new MouseAdapter() {



                @Override
                public void mouseEntered(MouseEvent me) {
                     b.setBackground(Color.GREEN);
                }

                @Override
                public void mouseExited(MouseEvent me) {
                     b.setBackground(Color.BLUE);
                }
            });

        b.addKeyListener(new KeyAdapter() {



                @Override
                public void keyPressed(KeyEvent ke) {


                 if(ke.getKeyCode()==10){
                    At.append("\n"+fie.getText());
                }
                }


            });

        b.addActionListener(new ActionListener() {

                public void actionPerformed(ActionEvent ae) {
                  At.append("\n"+fie.getText());
                }
            });

m.addActionListener(new ActionListener() {

                public void actionPerformed(ActionEvent ae) {
                  
                }
            });




        f.addWindowListener(new WindowAdapter(){
    public void windowClosing(WindowEvent ev){
        System.exit(0);
    }
    });


        f.setSize(600, 600);

        f.setVisible(true);





        }
    }





    public static void main(String[] args) {
        Ventana v=new Ventana();


    }

}
